﻿using DevExpress.XtraSplashScreen;
using Jupiter.Common.Form;

namespace Card.Make.Pro.Application.Helper
{
    public class LoadingHelper
    {
        /// <summary>
        /// 淡入
        /// </summary>
        private const bool FadeIn = false;
        /// <summary>
        /// 淡出
        /// </summary>
        private const bool FadeOut = true;
        /// <summary>
        /// 如果已经显示抛出异常
        /// </summary>
        private const bool ThrowExceptionIfIsAlreadyShown = false;
        /// <summary>
        /// 如果已经关闭抛出异常
        /// </summary>
        private const bool ThrowExceptionIfIsAlreadyClosed = false;

        /// <summary>
        /// 关闭
        /// </summary>
        public static void Close()
        {

            if (SplashScreenManager.Default != null)
            {
                SplashScreenManager.CloseForm(ThrowExceptionIfIsAlreadyClosed);
            }
        }
        /// <summary>
        /// 打开
        /// </summary>
        public static void Open()
        {
            Close();
            SplashScreenManager.ShowForm(null, typeof(Wait), FadeIn, FadeOut, ThrowExceptionIfIsAlreadyShown);
        }
    }
}
